﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace wdss.WebServices
{
    /// <summary>
    /// Summary description for CheckInService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    //[ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class CheckInService : System.Web.Services.WebService
    {

        public CheckInService()
        {

            //Uncomment the following line if using designed components 
            //InitializeComponent(); 
        }

        [WebMethod]
        public string CheckInDocument(int docId, int userID)
        {
            if (docId != 0)
            {
                SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ConnectionString);
                SqlCommand doclist = new SqlCommand("sp_DocumentCheckIn", connect);
                doclist.CommandType = CommandType.StoredProcedure;
                doclist.Parameters.Add(new SqlParameter("@par_userid", SqlDbType.Int)).Value = userID;
                doclist.Parameters.Add(new SqlParameter("@par_docid", SqlDbType.Int)).Value = docId;

                try
                {
                    connect.Open();
                    doclist.ExecuteNonQuery();
                    connect.Close();

                }
                catch (SqlException)
                {
                    Server.Transfer("~/GUI/Error.aspx");
                }
            }


            return "Document Checked in";

        }
    
    }
}
